package top.shen33.yang.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.util.ArrayList;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author oreilly
 * @since 2018-08-23
 */
public class RbacPermission extends Model<RbacPermission> {

private static final long serialVersionUID = 1L;

        @TableId(value = "sid", type = IdType.AUTO)
        private Integer sid;
        private String name;
        private String url;
        private Integer type;
        private Integer parentId;


        @TableField(exist = false)
        @JsonIgnore
        private RbacPermission parent;

        @TableField(exist = false)
        private List<RbacPermission> children;

        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private Date createTime;


    public RbacPermission getParent() {
        return parent;
    }

    public void setParent(RbacPermission parent) {
        this.parent = parent;
    }

    public String getParentName(){

        if(parent ==null ){
            return "";
        }
        return parent.getName();
    }

    public List<RbacPermission> getChildren() {
        return children;
    }

    public void setChildren(List<RbacPermission> children) {
        this.children = children;
    }

    public Integer getSid() {
            return sid;
            }

        public void setSid(Integer sid) {
            this.sid = sid;
            }

    public String getName() {
            return name;
            }

        public void setName(String name) {
            this.name = name;
            }

    public String getUrl() {
            return url;
            }

        public void setUrl(String url) {
            this.url = url;
            }

    public Integer getType() {
            return type;
            }

        public void setType(Integer type) {
            this.type = type;
            }

    public Integer getParentId() {
            return parentId;
            }

        public void setParentId(Integer parentId) {
            this.parentId = parentId;
            }

    public Date getCreateTime() {
            return createTime;
            }

        public void setCreateTime(Date createTime) {
            this.createTime = createTime;
            }

@Override
protected Serializable pkVal() {
            return this.sid;
        }

@Override
public String toString() {
        return "RbacPermission{" +
                ", sid=" + sid +
                ", name=" + name +
                ", url=" + url +
                ", type=" + type +
                ", parentId=" + parentId +
                ", createTime=" + createTime +
        "}";
        }
        }
